package com.cookor.poi.modules.phy.service;

import com.cookor.poi.common.persistence.DataEntity;
import com.cookor.poi.common.persistence.Page;
import com.cookor.poi.common.service.CrudService;
import com.cookor.poi.modules.phy.dao.TTempNoticeDao;
import com.cookor.poi.modules.phy.entity.TTempNotice;
import java.util.List;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class TTempNoticeService extends CrudService<TTempNoticeDao, TTempNotice> {
  public TTempNotice get(String id) {
    return (TTempNotice)super.get(id);
  }
  
  public List<TTempNotice> findList(TTempNotice tTempNotice) {
    return super.findList( tTempNotice);
  }
  
  public Page<TTempNotice> findPage(Page<TTempNotice> page, TTempNotice tTempNotice) {
    return super.findPage(page,  tTempNotice);
  }
  
  public TTempNotice getByParam(Integer tenantId, Integer type) {
    return ((TTempNoticeDao)this.dao).getByParam(tenantId, type);
  }
  
  @Transactional(readOnly = false)
  public void save(TTempNotice tTempNotice) {
    super.save( tTempNotice);
  }
  
  @Transactional(readOnly = false)
  public void delete(TTempNotice tTempNotice) {
    super.delete( tTempNotice);
  }
  
  @Transactional(readOnly = false)
  public void mySave(TTempNotice tTempNotice) throws Exception {
    if (getByParam(tTempNotice.getTenantId(), tTempNotice.getType()) != null)
      throw new Exception("该机构已存在该种类型消息模板"); 
    super.save( tTempNotice);
  }
}
